package com.byref.liteflowdemo.cmp.order;

import com.yomahub.liteflow.core.NodeBooleanComponent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author BYREF
 */
@Component("checkStock")
@Slf4j
public class CheckStockCmp extends NodeBooleanComponent {
    @Override
    public boolean processBoolean() {
        OrderContext orderContext = this.getContextBean(OrderContext.class);
        log.info("开始执行CheckStockCmp[orderContext: {}]", orderContext);
        if ("iphone".equalsIgnoreCase(orderContext.getProductId())) {
            return orderContext.getAmount() >= 10;

        }
        return true;
    }
}
